package com.sam.demo.config;

public class DataSourceContextHolder {
    private static final ThreadLocal<String> holder = new ThreadLocal<>();

    public static void setDataSource(String type) {
        System.out.println("set..." + type);
        holder.set(type);
    }

    public static String getDataSource() {
        String lookUpKey = holder.get();
        System.out.println("get..." + lookUpKey);
        return lookUpKey == null ? JpaDataSourceConfigCommon.PRIMARY_DATASOURCE_KEY : lookUpKey;
    }

    public static void clear() {
        holder.remove();
    }
}
